<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>sticky</title>
	</head>
	<!-- 
    sticky元素的父级元素需要有固定宽度或者最大宽度，不能自适应
 -->

	<body>
		<style>
			* {
				margin: 0;
			}

			.main-container {
				height: 100vh;
				overflow: auto;
			}

			.main-content {
				min-height: 800px;
				background: orange;
			}

			.main-footer {
				height: 50px;
				background: deeppink;
				position: -webkit-sticky;
				position: sticky;
				bottom: 0;
			}

			.main-header {
				height: 50px;
				background: red;
				position: -webkit-sticky;
				position: sticky;
				top: 0;
			}
		</style>
		<main class="main-container">
			<header class="main-header">HEADER</header>
			<div class="main-content">MAIN CONTENT</div>
			<footer class="main-footer">FOOTER</footer>
		</main>
	</body>
</html>
